<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>day01 去重</title>
</head>

<body>
    <div></div>
</body>
<script>
    var arr = [1, 2, 3, 4, 4, 55, 12, 12, 134, 2, 43, 2]
    //  1
    var newArr = new Set(arr)
    console.log(newArr);

    // 2
    function fn(arr) {
        return arr.filter((item, index, arr) => arr.indexOf(item) === index)
    }
    console.log(fn(arr))
    // 3

    function fn(arr) {
        let newArr = []
        arr.forEach((val) => {
            if (newArr.indexOf(val) == -1) {
                newArr.push(val)
            }
        })
        return newArr
    }
    console.log(fn(arr))
</script>

</html>